import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import request from 'utils/request';
import { CPAAS_FILE, CPAAS_IAM, CPAAS_PLATFORM } from 'utils/config';
import { getCurrentOrganizationId, isTenantRoleLevel } from 'utils/utils';
/**
 * 获取当前用户的信息
 */

export function userInfoQuerySelf(_x) {
  return _userInfoQuerySelf.apply(this, arguments);
}
/**
 * userInfoUpdateRealName-修改 昵称
 * @param {String} realName - 昵称
 */

function _userInfoQuerySelf() {
  _userInfoQuerySelf = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(query) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/self/detail"), {
              method: 'GET',
              query: query
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _userInfoQuerySelf.apply(this, arguments);
}

export function userInfoUpdateRealName(_x2) {
  return _userInfoUpdateRealName.apply(this, arguments);
}
/**
 * userInfoQueryRoleDataSource-查询当前登录用户所拥有的角色
 */

function _userInfoUpdateRealName() {
  _userInfoUpdateRealName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(realName) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/real-name"), {
              method: 'PUT',
              query: {
                realName: realName
              }
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _userInfoUpdateRealName.apply(this, arguments);
}

export function userInfoQueryRoleDataSource() {
  return _userInfoQueryRoleDataSource.apply(this, arguments);
}
/**
 * userInfoUpdateDefaultRole-修改 默认角色
 * @param {Number} organizationId - 租户id
 * @param {String|Number} roleId - 修改的 默认角色id
 */

function _userInfoQueryRoleDataSource() {
  _userInfoQueryRoleDataSource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            return _context3.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/member-roles/self-roles"), {
              method: 'GET'
            }));

          case 1:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _userInfoQueryRoleDataSource.apply(this, arguments);
}

export function userInfoUpdateDefaultRole(_x3, _x4) {
  return _userInfoUpdateDefaultRole.apply(this, arguments);
}
/**
 * userInfoQueryCompanyDataSource-查询当前登录用户所拥有的公司
 * @param {!Number} organizationId - 当前登录用户的租户id
 */

function _userInfoUpdateDefaultRole() {
  _userInfoUpdateDefaultRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(organizationId, roleId) {
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            return _context4.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/default-role"), {
              method: 'PUT',
              query: {
                roleId: roleId,
                tenantId: organizationId
              }
            }));

          case 1:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _userInfoUpdateDefaultRole.apply(this, arguments);
}

export function userInfoQueryCompanyDataSource(_x5) {
  return _userInfoQueryCompanyDataSource.apply(this, arguments);
}
/**
 * userInfoUpdateDefaultCompany-修改 默认公司
 * @param {String|Number} companyId - 修改的 默认公司id
 */

function _userInfoQueryCompanyDataSource() {
  _userInfoQueryCompanyDataSource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(organizationId) {
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            return _context5.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/companies/list-by-current-user"), {
              method: 'GET',
              query: {
                enabledFlag: 1
              }
            }));

          case 1:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _userInfoQueryCompanyDataSource.apply(this, arguments);
}

export function userInfoUpdateDefaultCompany(_x6, _x7) {
  return _userInfoUpdateDefaultCompany.apply(this, arguments);
}
/**
 * 修改密码
 * @param {Object} params 验证信息
 * @param {String} params.password 新密码
 * @param {String} params.originalPassword 旧密码
 */

function _userInfoUpdateDefaultCompany() {
  _userInfoUpdateDefaultCompany = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(organizationId, companyId) {
    return _regeneratorRuntime.wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            return _context6.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/default-company"), {
              method: 'PUT',
              query: {
                companyId: companyId,
                tenantId: organizationId
              }
            }));

          case 1:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));
  return _userInfoUpdateDefaultCompany.apply(this, arguments);
}

export function userInfoUpdatePassword(_x8) {
  return _userInfoUpdatePassword.apply(this, arguments);
}
/**
 * 验证 身份
 * @param {Object} params 校验信息
 * @param {String} params.captcha 验证码
 * @param {String} params.captchaKey 当前验证码的 key
 */

function _userInfoUpdatePassword() {
  _userInfoUpdatePassword = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref) {
    var password, originalPassword;
    return _regeneratorRuntime.wrap(function _callee7$(_context7) {
      while (1) {
        switch (_context7.prev = _context7.next) {
          case 0:
            password = _ref.password, originalPassword = _ref.originalPassword;
            return _context7.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/password"), {
              method: 'PUT',
              body: {
                originalPassword: originalPassword,
                password: password
              }
            }));

          case 2:
          case "end":
            return _context7.stop();
        }
      }
    }, _callee7);
  }));
  return _userInfoUpdatePassword.apply(this, arguments);
}

export function userInfoValidatePre(_x9) {
  return _userInfoValidatePre.apply(this, arguments);
}
/**
 * 向对应的手机号发送验证码
 * @param {Object} params 验证手机号
 * @param {String} params.phone 手机号
 */

function _userInfoValidatePre() {
  _userInfoValidatePre = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params) {
    return _regeneratorRuntime.wrap(function _callee8$(_context8) {
      while (1) {
        switch (_context8.prev = _context8.next) {
          case 0:
            return _context8.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/captcha/pre-validate"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context8.stop();
        }
      }
    }, _callee8);
  }));
  return _userInfoValidatePre.apply(this, arguments);
}

export function userInfoPostOldPhoneCaptcha(_x10) {
  return _userInfoPostOldPhoneCaptcha.apply(this, arguments);
}
/**
 * 绑定未绑定的手机号
 */

function _userInfoPostOldPhoneCaptcha() {
  _userInfoPostOldPhoneCaptcha = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(params) {
    return _regeneratorRuntime.wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            return _context9.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/phone/send-captcha"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9);
  }));
  return _userInfoPostOldPhoneCaptcha.apply(this, arguments);
}

export function userInfoValidateUnCheckedPhone(_x11) {
  return _userInfoValidateUnCheckedPhone.apply(this, arguments);
}
/**
 * 向旧邮箱发送验证码
 */

function _userInfoValidateUnCheckedPhone() {
  _userInfoValidateUnCheckedPhone = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(params) {
    return _regeneratorRuntime.wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            return _context10.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/phone/authenticate"), {
              method: 'PUT',
              query: params
            }));

          case 1:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10);
  }));
  return _userInfoValidateUnCheckedPhone.apply(this, arguments);
}

export function userInfoPostOldEmailCaptcha(_x12) {
  return _userInfoPostOldEmailCaptcha.apply(this, arguments);
}
/**
 * 向对应新的邮箱发送验证码
 * @param {Object} params 邮箱
 * @param {String} params.email 邮箱
 */

function _userInfoPostOldEmailCaptcha() {
  _userInfoPostOldEmailCaptcha = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(params) {
    return _regeneratorRuntime.wrap(function _callee11$(_context11) {
      while (1) {
        switch (_context11.prev = _context11.next) {
          case 0:
            return _context11.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/email/send-captcha"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context11.stop();
        }
      }
    }, _callee11);
  }));
  return _userInfoPostOldEmailCaptcha.apply(this, arguments);
}

export function userInfoPostNewEmailCaptcha(_x13) {
  return _userInfoPostNewEmailCaptcha.apply(this, arguments);
}
/**
 * 绑定未绑定的邮箱
 */

function _userInfoPostNewEmailCaptcha() {
  _userInfoPostNewEmailCaptcha = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(params) {
    return _regeneratorRuntime.wrap(function _callee12$(_context12) {
      while (1) {
        switch (_context12.prev = _context12.next) {
          case 0:
            return _context12.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/email-new/send-captcha"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context12.stop();
        }
      }
    }, _callee12);
  }));
  return _userInfoPostNewEmailCaptcha.apply(this, arguments);
}

export function userInfoValidateUnCheckedEmail(_x14) {
  return _userInfoValidateUnCheckedEmail.apply(this, arguments);
}
/**
 * 验证新的 邮箱 和 验证码 是否匹配
 * @param {Object} params 验证email 与 对应的code
 * @param {String} params.email 邮箱
 * @param {String} params.captcha 验证码
 * @param {String} params.captchaKey 原手机号的校验码
 * @param {String} params.lastCheckKey 原手机号和验证码的校验码
 */

function _userInfoValidateUnCheckedEmail() {
  _userInfoValidateUnCheckedEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(params) {
    return _regeneratorRuntime.wrap(function _callee13$(_context13) {
      while (1) {
        switch (_context13.prev = _context13.next) {
          case 0:
            return _context13.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/email/authenticate"), {
              method: 'PUT',
              query: params
            }));

          case 1:
          case "end":
            return _context13.stop();
        }
      }
    }, _callee13);
  }));
  return _userInfoValidateUnCheckedEmail.apply(this, arguments);
}

export function userInfoValidateNewEmail(_x15) {
  return _userInfoValidateNewEmail.apply(this, arguments);
}
/**
 * 验证登录密码是不是正确的
 * @param {Object} params 验证信息
 * @param {String} params.password 密码
 */

function _userInfoValidateNewEmail() {
  _userInfoValidateNewEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(params) {
    return _regeneratorRuntime.wrap(function _callee14$(_context14) {
      while (1) {
        switch (_context14.prev = _context14.next) {
          case 0:
            return _context14.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/email-new/validate-captcha"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context14.stop();
        }
      }
    }, _callee14);
  }));
  return _userInfoValidateNewEmail.apply(this, arguments);
}

export function userInfoValidatePrePassword(_x16) {
  return _userInfoValidatePrePassword.apply(this, arguments);
}
/**
 * 向对应新的手机号发送验证码
 * @param {Object} params 验证手机号
 * @param {String} params.phone 手机号
 */

function _userInfoValidatePrePassword() {
  _userInfoValidatePrePassword = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(params) {
    return _regeneratorRuntime.wrap(function _callee15$(_context15) {
      while (1) {
        switch (_context15.prev = _context15.next) {
          case 0:
            return _context15.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/password/pre-validate"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context15.stop();
        }
      }
    }, _callee15);
  }));
  return _userInfoValidatePrePassword.apply(this, arguments);
}

export function userInfoPostNewPhoneCaptcha(_x17) {
  return _userInfoPostNewPhoneCaptcha.apply(this, arguments);
}
/**
 * 验证新的 手机号 和 验证码 是否匹配
 * @param {Object} params 验证手机号 与 对应的code
 * @param {String} params.phone 手机号
 * @param {String} params.code 验证码
 */

function _userInfoPostNewPhoneCaptcha() {
  _userInfoPostNewPhoneCaptcha = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(params) {
    return _regeneratorRuntime.wrap(function _callee16$(_context16) {
      while (1) {
        switch (_context16.prev = _context16.next) {
          case 0:
            return _context16.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/phone-new/send-captcha"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context16.stop();
        }
      }
    }, _callee16);
  }));
  return _userInfoPostNewPhoneCaptcha.apply(this, arguments);
}

export function userInfoValidateNewPhone(_x18) {
  return _userInfoValidateNewPhone.apply(this, arguments);
}
/**
 * 查询当前登陆用户的 默认公司
 * @async
 * @param {Number} organizationId - 登陆用户的租户id
 * @param {Number} companyId - 登陆用户的默认公司Id
 */

function _userInfoValidateNewPhone() {
  _userInfoValidateNewPhone = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(params) {
    return _regeneratorRuntime.wrap(function _callee17$(_context17) {
      while (1) {
        switch (_context17.prev = _context17.next) {
          case 0:
            return _context17.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/phone-new/validate-captcha"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context17.stop();
        }
      }
    }, _callee17);
  }));
  return _userInfoValidateNewPhone.apply(this, arguments);
}

export function userInfoCompanyQuery(_x19, _x20) {
  return _userInfoCompanyQuery.apply(this, arguments);
}
/**
 * 变更用户的默认语言选项
 * @async
 * @function updateDefaultLanguage
 * @param {!string} params.languageCode - 语言编码
 * @returns fetch Promise
 */

function _userInfoCompanyQuery() {
  _userInfoCompanyQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(organizationId, companyId) {
    return _regeneratorRuntime.wrap(function _callee18$(_context18) {
      while (1) {
        switch (_context18.prev = _context18.next) {
          case 0:
            return _context18.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/companies/").concat(companyId), {
              method: 'GET'
            }));

          case 1:
          case "end":
            return _context18.stop();
        }
      }
    }, _callee18);
  }));
  return _userInfoCompanyQuery.apply(this, arguments);
}

export function updateDefaultLanguage(_x21) {
  return _updateDefaultLanguage.apply(this, arguments);
}
/**
 * 变更用户的默认菜单布局选项
 * @async
 * @function updateDefaultMenu
 * @param {!string} params.
 * @returns fetch Promise
 */

function _updateDefaultLanguage() {
  _updateDefaultLanguage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(params) {
    return _regeneratorRuntime.wrap(function _callee19$(_context19) {
      while (1) {
        switch (_context19.prev = _context19.next) {
          case 0:
            return _context19.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/default-language"), {
              method: 'PUT',
              query: _objectSpread({}, params)
            }));

          case 1:
          case "end":
            return _context19.stop();
        }
      }
    }, _callee19);
  }));
  return _updateDefaultLanguage.apply(this, arguments);
}

export function updateDefaultMenu(_x22) {
  return _updateDefaultMenu.apply(this, arguments);
}
/**
 * 变更用户的默认时间/日期选项
 * @async
 * @function updateDefaultDate
 * @param {!string} params.dateFormat - 日期格式
 * @param {!string} params.timeFormat - 时间格式
 * @returns fetch Promise
 */

function _updateDefaultMenu() {
  _updateDefaultMenu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(params) {
    return _regeneratorRuntime.wrap(function _callee20$(_context20) {
      while (1) {
        switch (_context20.prev = _context20.next) {
          case 0:
            return _context20.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/config-items"), {
              method: 'PUT',
              query: _objectSpread({}, params)
            }));

          case 1:
          case "end":
            return _context20.stop();
        }
      }
    }, _callee20);
  }));
  return _updateDefaultMenu.apply(this, arguments);
}

export function updateDefaultDate(_x23) {
  return _updateDefaultDate.apply(this, arguments);
}
/**
 * 变更用户的默认时区选项
 * @async
 * @function updateDefaultTimeZone
 * @param {!string} params.timeZone - 时区编码
 * @returns fetch Promise
 */

function _updateDefaultDate() {
  _updateDefaultDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(params) {
    return _regeneratorRuntime.wrap(function _callee21$(_context21) {
      while (1) {
        switch (_context21.prev = _context21.next) {
          case 0:
            return _context21.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/datetime-format"), {
              method: 'PUT',
              query: _objectSpread({}, params)
            }));

          case 1:
          case "end":
            return _context21.stop();
        }
      }
    }, _callee21);
  }));
  return _updateDefaultDate.apply(this, arguments);
}

export function updateDefaultTimeZone(_x24) {
  return _updateDefaultTimeZone.apply(this, arguments);
}
/**
 * 验证邮箱是否已注册
 * @param {String} params.email - 邮箱
 */

function _updateDefaultTimeZone() {
  _updateDefaultTimeZone = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(params) {
    return _regeneratorRuntime.wrap(function _callee22$(_context22) {
      while (1) {
        switch (_context22.prev = _context22.next) {
          case 0:
            return _context22.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/time-zone"), {
              method: 'PUT',
              query: _objectSpread({}, params)
            }));

          case 1:
          case "end":
            return _context22.stop();
        }
      }
    }, _callee22);
  }));
  return _updateDefaultTimeZone.apply(this, arguments);
}

export function validateEmailRegisterService(_x25) {
  return _validateEmailRegisterService.apply(this, arguments);
}
/**
 * 验证手机是否已注册
 * @param {String} params.phone - 手机
 */

function _validateEmailRegisterService() {
  _validateEmailRegisterService = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(params) {
    return _regeneratorRuntime.wrap(function _callee23$(_context23) {
      while (1) {
        switch (_context23.prev = _context23.next) {
          case 0:
            return _context23.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/validation/email"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context23.stop();
        }
      }
    }, _callee23);
  }));
  return _validateEmailRegisterService.apply(this, arguments);
}

export function validatePhoneRegisterService(_x26) {
  return _validatePhoneRegisterService.apply(this, arguments);
}
/**
 * 获取可上传文件的类型和大小
 * @param {Number} params.tenantId
 * @param {String} params.bucketName
 */

function _validatePhoneRegisterService() {
  _validatePhoneRegisterService = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(params) {
    return _regeneratorRuntime.wrap(function _callee24$(_context24) {
      while (1) {
        switch (_context24.prev = _context24.next) {
          case 0:
            return _context24.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/validation/phone"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context24.stop();
        }
      }
    }, _callee24);
  }));
  return _validatePhoneRegisterService.apply(this, arguments);
}

export function fetchEnabledFile(_x27) {
  return _fetchEnabledFile.apply(this, arguments);
}
/**
 * 上传裁剪好的头像
 * @async
 * @function uploadAvatar
 * @returns {object} fetch Promise
 */

function _fetchEnabledFile() {
  _fetchEnabledFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(params) {
    return _regeneratorRuntime.wrap(function _callee25$(_context25) {
      while (1) {
        switch (_context25.prev = _context25.next) {
          case 0:
            return _context25.abrupt("return", request("".concat(CPAAS_FILE, "/v1/").concat(isTenantRoleLevel() ? "".concat(getCurrentOrganizationId(), "/") : '', "upload-configs/detail"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context25.stop();
        }
      }
    }, _callee25);
  }));
  return _fetchEnabledFile.apply(this, arguments);
}

export function uploadAvatar(_x28) {
  return _uploadAvatar.apply(this, arguments);
}
/**
 * 保存头像
 * @async
 * @function saveAvatar
 * @param {String} params - 保存参数
 */

function _uploadAvatar() {
  _uploadAvatar = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(params) {
    var formData;
    return _regeneratorRuntime.wrap(function _callee26$(_context26) {
      while (1) {
        switch (_context26.prev = _context26.next) {
          case 0:
            formData = new FormData();
            formData.append('bucketName', params.bucketName);
            formData.append('directory', params.directory);
            formData.append('fileName', params.uploadImgName);
            formData.append('file', params.image, params.uploadImgName);
            return _context26.abrupt("return", request("".concat(CPAAS_FILE, "/v1/").concat(isTenantRoleLevel() ? "".concat(params.organizationId, "/") : '', "files/multipart"), {
              method: 'POST',
              type: 'FORM',
              processData: false,
              // 不会将 data 参数序列化字符串
              body: formData,
              responseType: 'text'
            }));

          case 6:
          case "end":
            return _context26.stop();
        }
      }
    }, _callee26);
  }));
  return _uploadAvatar.apply(this, arguments);
}

export function saveAvatar(_x29) {
  return _saveAvatar.apply(this, arguments);
}
/**
 * 获取第三方绑定
 * @async
 * @function saveAvatar
 * @param {String} params - 保存参数
 */

function _saveAvatar() {
  _saveAvatar = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(params) {
    return _regeneratorRuntime.wrap(function _callee27$(_context27) {
      while (1) {
        switch (_context27.prev = _context27.next) {
          case 0:
            return _context27.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/avatar"), {
              method: 'PUT',
              query: {
                avatar: params
              }
            }));

          case 1:
          case "end":
            return _context27.stop();
        }
      }
    }, _callee27);
  }));
  return _saveAvatar.apply(this, arguments);
}

export function fetchOpenAccountList() {
  return _fetchOpenAccountList.apply(this, arguments);
}
/**
 * 解除第三方绑定
 * @async
 * @function unBindOpenAccount
 * @param {String} params - 保存参数
 */

function _fetchOpenAccountList() {
  _fetchOpenAccountList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
    return _regeneratorRuntime.wrap(function _callee28$(_context28) {
      while (1) {
        switch (_context28.prev = _context28.next) {
          case 0:
            return _context28.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/user-open-account"), {
              method: 'GET'
            }));

          case 1:
          case "end":
            return _context28.stop();
        }
      }
    }, _callee28);
  }));
  return _fetchOpenAccountList.apply(this, arguments);
}

export function unBindOpenAccount(_x30) {
  return _unBindOpenAccount.apply(this, arguments);
}
/**
 * 绑定三方账户之前获取认证地址
 * @async
 * @function saveAvatar
 * @param {String} params - 保存参数
 */

function _unBindOpenAccount() {
  _unBindOpenAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(params) {
    return _regeneratorRuntime.wrap(function _callee29$(_context29) {
      while (1) {
        switch (_context29.prev = _context29.next) {
          case 0:
            return _context29.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/user-open-account/unbind"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context29.stop();
        }
      }
    }, _callee29);
  }));
  return _unBindOpenAccount.apply(this, arguments);
}

export function beforeBind(_x31) {
  return _beforeBind.apply(this, arguments);
}

function _beforeBind() {
  _beforeBind = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(params) {
    return _regeneratorRuntime.wrap(function _callee30$(_context30) {
      while (1) {
        switch (_context30.prev = _context30.next) {
          case 0:
            return _context30.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/user-open-account/before-bind"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context30.stop();
        }
      }
    }, _callee30);
  }));
  return _beforeBind.apply(this, arguments);
}